package com.example.demo.jmx;

import javax.management.*;
import java.io.IOException;
import java.lang.management.ManagementFactory;

public class JMXBean {

    public static void main(String[] args) throws MalformedObjectNameException, NotCompliantMBeanException, InstanceAlreadyExistsException, MBeanRegistrationException, IOException {

        MBeanServer beanServer = ManagementFactory.getPlatformMBeanServer();

        ObjectName objectName = new ObjectName("com.example.demo.jmx.Mechine:type=mechine");

        MechineMBean mechineMBean = new Mechine();

        beanServer.registerMBean(mechineMBean, objectName);

        // 保持线程运行
        System.in.read();


    }
}
